Show CPU usage and time since thread started to sly-threads view #598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was debugging a multi-threaded program where some threads would hang at 100% cpu so I added some extra info to the thread view to spot it easier. It is only for sbcl and linux. Supporting other compilers and OS I think is possible if there is interest and someone available to test. I first added to the sbcl backend
thread-attributes
a:tid
attribute with the OStid
/pid
for each thread. Then on the elisp side if the:tid
attribute is present, it will also add the elapsed time since the thread started, and the percent cpu usage since the last update of the threads buffer. The elapsed time it gets from emacsprocess-attributes
function which is cross platform, however the cpu time returned by emacs 'process-attributes' for a giventid
is for the process not the thread. As on linux emacs is reading/proc/tid/stat
which does have the correct elapsed time per thread but has the cpu usage for the whole process, so I added a function to get the info from/proc/sly-pid/task/tid/stat
Here's a screenshot of it in action:
I'm thinking maybe I should remove the TID column cause the user probably doesn't care to see it, and make the time show in a nice format, I could just call
proced-format-time
but then sly would have to require proced.Is just an idea and demo of it, I doubt it's of quality to merge into sly as is, I'm new at emacs and lisp so any feedback is welcome.